<template>
	<view class="">
		<!-- 头部 -->
		<view class="u-p-30 bg_FFFFFF u-flex u-row-between">
			<view class="u-flex">
				<view class="" style="width: 7rpx ;height: 28rpx; background-color: #FF2736FF; border-radius: 3rpx;">
				</view>
				<view class="u-m-l-20">中奖历史</view>
			</view>
			<view @click="dayShow=true" class="u-flex u-b-r-14"
				style="border: 1rpx solid #FF2736FF;padding: 10rpx 30rpx;">
				<u-icon name="calendar" color='#FF2736FF'></u-icon>
				<view class="u-font-20 u-p-10">{{params.time_length==''?'选择天数':`${params.time_length}天`}}</view>
				<u-icon name="arrow-down"></u-icon>
			</view>
		</view>
		<!-- 中奖列表信息 -->
		<view class=" u-p-20 ">
			<view class="u-p-20  bg_FFFFFF" v-for="(item,index) in list" :key="index" >
				<view class=" u-flex " style="border-bottom: 1rpx solid #E2EBF4;">
					<view class="u-w-700 u-m-l-16 u-p-b-28">
						<view class="u-flex u-row-between u-p-t-6">
							<view class="cl_1C1C1CFF u-weight ">{{item.prize_title}}</view>
							<view class="cl_898989FF u-font-20">
								{{$u.timeFormat(item.create_time, 'yyyy-mm-dd hh:MM:ss')}}</view>
						</view>
						<view class="u-m-t-20 u-flex u-row-between">
							<view class="cl_454545FF u-font-20">{{item.status_text}}</view>
							<view  v-if="item.status==4" class="u-b-r-10 u-w-150 u-l-h-54 u-h-54 u-font-24 u-text-center"
								style="border: 1rpx solid #FC3533;color: #FC3533;" @click="$u.route(`pages/home/logistics?id=${item.id}`)">查看物流
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 加载更多 -->
		<u-loadmore :status="status" icon-type="circle" margin-bottom="20" />
		<u-select v-model="dayShow" :list="dayList" @confirm="dayFirm"></u-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 天
				dayShow: false,
				dayList: [{
						value: 1,
						label: 1
					},
					{
						value: 5,
						label: 5
					},
					{
						value: 7,
						label: 7
					},
					{
						value: 10,
						label: 10
					},
					{
						value: 15,
						label: 15
					}
				],
				params: {
					page: 1,
					page_size: 20,
					time_length:''
				},
				status: 'loadmore',
				list: []
			}
		},
		onLoad() {
			this.clear()
			this.massage()
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.massage();
		},
		methods: {
			// 选择天数
			dayFirm(e){
				this.params.time_length=e[0].label
				this.clear()
				this.massage()
			},
			clear() {
				this.list = [];
				this.params.page = 1;
			},
			massage() {
				this.$api.good_list_massage(this.params, res => {
					if (res.data.code == 1) {
						if (res.data.data.luck_log_list.length < 20) {
							this.status = 'nomore';
						} else {
							this.params.page = this.params.page + 1;
							this.status = 'loadmore';
						}
						this.list = this.list.concat(res.data.data.luck_log_list);
						uni.stopPullDownRefresh();
					}
				})
			}
		}
	}
</script>

<style scoped>
	page {
		background: #F5F5F5FF !important;
	}
</style>
